package com.springboot.security.controller;

import org.springframework.security.access.annotation.Secured;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author wangning
 * @create 2021-05-18 16:12
 */
@RestController
public class MethodAuthController {
	@GetMapping("/admin")
	@Secured("ROLE_admin")
	public String admin() {
		return "hello admin";
	}

	@GetMapping("/user")
	@PreAuthorize("hasRole('USER')")
	public String user() {
		return "hello user";
	}
}
